from bdtime import tt

if 0:
    delta_print_dc = {
        1: [1, 10, 10],
        0.5: [1, 20, 10],
        0.2: [1, 50, 10],
        0.1: [1, 100, 10],
        0.01: [2, 1000, 10],
        0.001: [3, 10000, 10],
    }
    delta_print_t = 0.5  # 打印间隔


    tt.__init__()
    last_print_time = -1
    while tt.during(2):
        if tt.stop('alt + x', raise_error=False):
            print(f'*** stop record by user!')
            break

        delta_print_v = delta_print_dc[delta_print_t]
        now = tt.now(delta_print_v[0])
        if int(now * delta_print_v[1]) % delta_print_v[2] == 0 and now != last_print_time:
            print('now ---', now)
            last_print_time = now


if 1:
    tt.__init__()
    last_t = tt.now()
    while tt.during(10):
        tt.sleep(1)
        now = tt.now()
        delta_t = now - last_t
        last_t = now
        print('now:', now, '--- delta_t:', delta_t)

